ÿþ--[[ x: JX-API-08 Tðy: úQ“^US‹NöNYt \O€ÿkun åeg: 2025-1-29 eQãSýQpeÿ main ŸRý€ô‹f: 9hnc“eQpencRú^úQ“^USv^Ytøv”^;‘ “eQ„v Data { "workorderNo": "YT10023105655", "sourceSys": "è]f", "startTime": "", "endTime": "", "type": 0, "priority": 99, "data": [{ "startBit": "", "endBit": "", "endArea": "ZA2", "sourNo": "jx76543", "trayCode": "P90037073", "trayType": "ánXb" }, { "startBit": "", "endBit": "", "endArea": "ZA2", "sourNo": "jx76543", "trayCode": "P90099095", "trayType": "zzXb" }] } ôf9e°‹U_: V2.0 HAN 20241128 žX RTðSYt,gubè]fúQ“^\ON --]] wms_wh = require( "wms_wh" ) wms_base = require( "wms_base" ) function main(strLuaDEID) local nRet, strRetInfo -- ·ƒÖS¥cãS„vdatapenc local getinput nRet, getinput = m3.GetSysDataJson(strLuaDEID) if (nRet ~= 0) then lua.Error(strLuaDEID, debug.getinfo(1), "àeÕl·ƒÖSpencS!" .. getinput) end lua.Debug(strLuaDEID, debug.getinfo(1), "getinput", getinput) -- ÂSpeÀhåg if (getinput.sourceSys == nil or getinput.sourceSys == '') then lua.Error(strLuaDEID, debug.getinfo(1), "egnû|ß~penc:Nzz,÷‹ÀhågÂSpe") end if (getinput.type == nil or getinput.type == '') then lua.Error(strLuaDEID, debug.getinfo(1), "ûN¡R{|‹W:Nzz,÷‹ÀhågÂSpe") end if (getinput.priority == nil or getinput.priority == '') then lua.Error(strLuaDEID, debug.getinfo(1), "OHQ§~penc:Nzz,÷‹ÀhågÂSpe") end if (#getinput.data == 0) then lua.Error(strLuaDEID, debug.getinfo(1), "data P[penc:Nzz,÷‹ÀhågÂSpe") end local sourceSys = getinput.sourceSys local startBit,area_code,task local endArea,strCondition local trayCode,cntr_obj local sourNo local endBit local trayType local priority local errorMessages = {} local taskCondition,condition,loc_code -- M†S data peÄ~ ÿagRú^ûN¡R`l°‹U_ for n = 1, #getinput.data do startBit = getinput.data[n].startBit -- wËY'MO endArea = getinput.data[n].endArea -- È~¹p“^:S trayCode = getinput.data[n].trayCode -- XbØv÷S sourNo = getinput.data[n].sourNo -- N8nûN¡R÷S endBit = getinput.data[n].endBit -- È~¹p'MO trayType = getinput.data[n].trayType -- XbØv{|‹W priority = getinput.priority -- ûN¡ROHQ§~ if (trayCode == nil or trayCode == '') then table.insert(errorMessages, "™e±{"..trayCode.."XbØv÷S:Nzz,÷‹ÀhågÂSpe") goto continue end if (endArea == nil or endArea == '') then table.insert(errorMessages, "™e±{"..trayCode.."È~¹p“^:S:Nzz,÷‹ÀhågÂSpe") goto continue end if (sourNo == nil or sourNo == '') then table.insert(errorMessages, "™e±{"..trayCode.." N8nûN¡R÷S:Nzz,÷‹ÀhågÂSpe") goto continue end -- ågâ‹ûN¡R`l/f&Tò]X[(Wøv TûN¡RÿXbØv÷S0 N8nûN¡R÷S0¶r` ÿ condition = "(S_CNTR_CODE = '" .. trayCode .. "' AND N_B_STATE IN (0,1)) OR (S_SOURNO = '" .. sourNo .. "')" nRet, strRetInfo = mobox.existThisData(strLuaDEID, "JX_Task", condition) if (nRet ~= 0) then table.insert(errorMessages, "ågâ‹ûN¡R`löeÑSuû|ß~•ï‹: " .. strRetInfo) goto continue end if (strRetInfo == "yes") then table.insert(errorMessages, "ûN¡R`l-Nò]X[(WXbØv÷S'" .. trayCode .. "'0egnû|ß~'" .. sourceSys .. "'ŒT N8nûN¡R÷S'" .. sourNo .. "'„vûN¡R ÿàeÕl͑ YRú^") goto continue end -- $R­e“^:S/f&TX[(W strCondition = "S_CODE='" .. endArea .. "'" nRet, strRetInfo = mobox.existThisData(strLuaDEID, "Area", strCondition) if (nRet ~= 0) then table.insert(errorMessages, "ÀhågÈ~¹p“^:S'" .. endArea .. "'öeÑSu•ï‹ ÿïSý€/f: " .. strRetInfo) goto continue end if (strRetInfo ~= "yes") then table.insert(errorMessages, "È~¹p“^:S'" .. endArea .. "' NX[(W ÿ÷‹Àhåg“eQ") goto continue end --$R­e¹[hVŒTegnû|ß~/f&Tù[„v N nRet, cntr_obj = wms_cntr.GetInfo( strLuaDEID, trayCode ) lua.Debug( strLuaDEID, debug.getinfo(1), "cntr_obj-->", cntr_obj ) if ( nRet ~= 0 ) then table.insert(errorMessages, "·ƒÖS¹[hVù[aŒ1Y%! "..cntr_obj) goto continue end if ( cntr_obj == '' or cntr_obj == nil ) then table.insert(errorMessages, "x = '"..trayCode.."'„vãb™e±{ NX[(W!") goto continue end if ( cntr_obj.source ~= 'è]f' ) then table.insert(errorMessages, "ãb™e±{x = '"..trayCode.."' N/fè]f„v") goto continue end -- 'MOŒTûN¡R`l°‹U_Rú^;‘ loc_code = wms_wh.GetLocCodeByCNTR(strLuaDEID, trayCode) if (loc_code == '') then table.insert(errorMessages, "™e±{"..trayCode..' N(W™e±{“^…Q!') goto continue end nRet, start_loc = wms_wh.GetLocInfo(loc_code) if (nRet ~= 0) then table.insert(errorMessages, "™e±{"..trayCode.."·ƒÖS'MO'" .. loc_code .. "'áOo`1Y%!") goto continue end area_code = start_loc.area_code if (area_code ~= wms_base.Get_sConst( strLuaDEID, "™e±{“^X[¨P:S" )) then table.insert(errorMessages, "™e±{"..trayCode.. "' N(WËz“^:Sÿ") goto continue end -- Rú^ûN¡R`l°‹U_ task = m3.AllocObject(strLuaDEID, "JX_Task") task.start_loc_code = startBit -- wËY'MO task.end_area_code = endArea -- È~¹p“^:S task.end_loc_code = endBit -- È~¹p'MO task.cntr_code = trayCode -- XbØv÷S task.sour_no = sourNo -- N8nûN¡R÷S task.tray_type = trayType -- XbØv{|‹W task.bs_no = getinput.workorderNo -- úQ“^US÷S task.source_sys = getinput.sourceSys -- egnû|ß~ task.priority = priority -- ûN¡ROHQ§~ task.task_type = "úQ“^" -- \ON{|‹W task.create_method = "JX-WMS" task.start_wh_code =wms_base.Get_sConst(strLuaDEID, "؞¤‹ÓN“^hƋ") --ÓN“^ T nRet, task = m3.CreateDataObj(strLuaDEID, task) if (nRet ~= 0) then table.insert(errorMessages, "Rú^ûN¡R`l1Y%ÿ" .. strRetInfo) end lua.Debug(strLuaDEID, debug.getinfo(1), "task", task) -- žX RN*NTðSۏ zRú^è]fúQ“^\ON local add_wfp = { wfp_type = 1, -- æ‰ÑSpencù[aŒ‹NöNÿcš[pencù[aŒhƋ ÿ cls = "JX_Task", obj_id = task.id, obj_name = "ûN¡R÷S'" .. task.sour_no .. "'è]fûN¡R-->Rú^è]fúQ“^\ON", trigger_event = "Rú^è]fúQ“^\ON" } nRet, strRetInfo = m3.AddSysWFP(strLuaDEID, add_wfp) if (nRet ~= 0) then table.insert(errorMessages, "AddSysWFP1Y%!" .. strRetInfo) end lua.Debug(strLuaDEID, debug.getinfo(1), "nRet", nRet) ::continue:: end -- ԏÞVÂSpe local result = { success = true, errCode = 0, errMsg = "" } if (#errorMessages > 0) then result.success = false result.errCode = 1 result.errMsg = table.concat(errorMessages, ",") end mobox.returnValue(strLuaDEID, 1, table2str(result)) lua.Debug(strLuaDEID, debug.getinfo(1), "result", result) end